<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
        "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8"/>
    <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no"/>
    <title>合同管理页面</title>
    <!-- plugins:css -->
    <link rel="stylesheet" href="../../vendors/iconfonts/mdi/css/materialdesignicons.min.css"/>
    <link rel="stylesheet" href="../../vendors/css/vendor.bundle.base.css"/>
    <link rel="stylesheet" href="../../data/styles.css"/>
    <!-- endinject -->
    <!-- inject:css -->
    <link rel="stylesheet" href="../../css/style.css"/>
    <!-- endinject -->
    <link rel="shortcut icon" href="../../images/favicon.png"/>
    <style type="text/css">
        ::-webkit-scrollbar {
            width: 6px;
            height: 10px;
        }

        ::-webkit-scrollbar-track {
            background-color: rgba(255, 255, 255, 0);
        }

        ::-webkit-scrollbar-thumb {
            background-color: rgba(255, 255, 255, 0);
            transition: background-color .3s;
        }

        ::-webkit-scrollbar-thumb:hover {
            width: 5px;
            background-color: rgba(200, 200, 200, 0.88);
            -webkit-border-radius: 5px;
            transition: background-color .3s;
        }

        .table {
            table-layout: auto !important;
            word-break: keep-all !important;
        }
    </style>
</head>
<body>
<input type="hidden" id="mApproveMoney" value=""/>
<div class="col-12 grid-margin stretch-card">
    <div class="card">
        <div class="card-body">
            <div class="page-header">
                <h3 class="page-title">
                    合同管理
                </h3>
                <nav aria-label="breadcrumb">
                    <ol class="breadcrumb">
                        <li class="breadcrumb-item"><a href="#">合同管理</a></li>
                        <li class="breadcrumb-item active" aria-current="page">贷中管理</li>
                    </ol>
                </nav>
            </div>
            <form class="form-inline" th:action="@{/contractManger/query}" id="queryForm">
                <input type="hidden" name="currentPageNo" value="1"/>
                <label class="sr-only" for="inlineFormInputName4">借款编号</label>
                <input type="text" th:value="${borrowOrderQuery?.queryBoId}" class="form-control mb-2 mr-sm-2"
                       id="inlineFormInputName4" placeholder="借款编号" name="queryBoId" size="5"/>
                <label class="sr-only" for="inlineFormInputName1">姓名</label>
                <input type="text" th:value="${borrowOrderQuery?.queryName}" class="form-control mb-2 mr-sm-2"
                       id="inlineFormInputName1" placeholder="姓名" name="queryName" size="5"/>
                <label class="sr-only" for="inlineFormInputName5">合同号</label>
                <input type="text" th:value="${borrowOrderQuery?.queryContractID}" class="form-control mb-2 mr-sm-2"
                       id="inlineFormInputName5" placeholder="合同号" name="queryContractID" size="5"/>
                <label class="sr-only" for="inlineFormInputName3">贷款类型</label>
                <select id="inlineFormInputName3" placeholder="贷款类型" class="form-control mb-2 mr-sm-2" name="queryType">
                    <option value="0">贷款类型</option>
                    <option th:each="HLoanProducts:${LoanTypes}" th:value="${HLoanProducts.productId}"
                            th:text="${HLoanProducts.loanType}"
                            th:selected="${borrowOrderQuery?.queryType == HLoanProducts.productId}"></option>
                </select>
                <!--<label class="sr-only" for="inlineFormInputName7">订单状态</label>-->
                <!--<select id="inlineFormInputName7" placeholder="订单状态" class="form-control mb-2 mr-sm-2" name="queryBoType">-->
                <!--<option value="0">订单状态</option>-->
                <!--<option value="终审通过" th:selected="${borrowOrderQuery?.queryBoType == '终审通过'}">待处理</option>-->
                <!--<option value="放款审批" th:selected="${borrowOrderQuery?.queryBoType == '放款审批'}">已完成</option>-->
                <!--</select>-->
                <input type="text" th:value="${borrowOrderQuery?.queryTime}"
                       class="demo-input form-control mb-2 mr-sm-2" name="queryTime" placeholder="请选择日期" id="test1"/>
                <button type="submit" class="btn btn-sm btn-gradient-primary mb-2">查询</button>
            </form>
            <div style="overflow: auto">
                <table class="table table-bordered">
                    <thead>
                    <tr>
                        <th>
                            借款编号
                        </th>
                        <th>
                            姓名
                        </th>
                        <th>
                            合同号
                        </th>
                        <th>
                            申请日期
                        </th>
                        <th>
                            申请额度
                        </th>
                        <th>
                            审批额度
                        </th>
                        <th>
                            合同金额
                        </th>
                        <th>
                            借款期限
                        </th>
                        <th>
                            贷款类型
                        </th>
                        <th>
                            还款方式
                        </th>
                        <th>
                            状态
                        </th>
                        <th>
                            操作
                        </th>
                    </tr>
                    </thead>
                    <tbody>
                    <tr th:each="borrowOrder:${borrowOrders}">
                        <td th:text="${borrowOrder.boId}"></td>
                        <td th:text="${borrowOrder.user?.userName}"></td>
                        <td th:utext="${borrowOrder.contract?.cid}">----</td>
                        <td th:text="${borrowOrder.oCreateTime}"></td>
                        <td th:text="${borrowOrder.oWantedMoney}"></td>
                        <td th:if="${checkState.mType eq 3}" th:each="checkState:${borrowOrder.checkStates}"
                            th:text="${checkState.mApproveMoney}"></td>
                        <td th:utext="${borrowOrder.contract?.ccontractMoney}" class="text">----</td>
                        <td th:text="${borrowOrder.oLoanTime}"></td>
                        <td th:text="${borrowOrder.hLoanProducts?.loanType}"></td>
                        <td th:text="${borrowOrder.oRepayMode}"></td>
                        <td style="color: #b66dff" th:text="${borrowOrder.boType}"></td>
                        <td th:if="${#strings.isEmpty(borrowOrder.contract?.cid)}">
                            <a style="background-color: #f2edf3;font-weight: bold" class="Check" data-toggle="modal"
                               data-target="#myModal">
                                发送合同模板
                            </a>
                        </td>
                        <td th:if="${not #strings.isEmpty(borrowOrder.contract?.cid)}">
                            <a style="color: lightblue" class="checkConstract">预览合同</a>
                        </td>
                    </tr>
                    </tbody>
                </table>
            </div>

            <div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
                <div class="modal-dialog" role="document">
                    <div class="modal-content">
                        <div class="modal-header">
                            <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span
                                    aria-hidden="true">&times;</span></button>
                        </div>
                        <h4 class="modal-title text-center" id="myModalLabel">合同模板选择</h4>
                        <form class="form-inline" id="CheckStatecheck">
                            <input type="hidden" id="CheckStatecheckboId" name="boId" value="0"/>
                            <div class="modal-body">
                                <div class="form-group">
                                    <label for="exampleInputName3" class="text-left">合同模板选择：</label><br/>
                                    <select name="contractNo" class="form-control" id="exampleInputName3">
                                        <option th:each="hContractTemplate:${hContractTemplates}"
                                                th:value="${hContractTemplate.contractNo}"
                                                th:text="${hContractTemplate.contractName}"></option>
                                    </select>
                                </div>
                            </div>
                            <div class="modal-footer">
                                <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
                                <button type="button" id="addBtn" class="btn btn-primary" data-dismiss="modal">保存
                                </button>
                            </div>
                        </form>
                    </div>
                </div>
            </div>

        </div>
    </div>
</div>
<!--跳转页面-->
<div class="page-bar">
    <ul class="page-num-ul clearfix">
        <li>共<span th:text="${page.totalCount}"></span>条记录&nbsp;&nbsp; <span
                th:text="${page.pageIndex}"></span>/<span th:text="${page.totalPageCount}"></span> 页
        </li>
        <button th:onclick="'javascript:pageQry(document.forms[0],1)'" th:if="${page.pageIndex gt 1 }">首页
        </button>
        <button th:onclick="'javascript:pageQry(document.forms[0],'+${page.pageIndex - 1}+')'"
                th:if="${page.pageIndex gt 1 }">上一页
        </button>

        <button th:onclick="'javascript:pageQry(document.forms[0],'+${page.pageIndex + 1}+')'"
                th:if="${page.pageIndex lt page.totalPageCount}">下一页
        </button>
        <button th:onclick="'javascript:pageQry(document.forms[0],'+${page.totalPageCount}+')'"
                th:if="${page.pageIndex lt page.totalPageCount}">最后一页
        </button>
    </ul>
    <span class="page-go-form"><label>跳转至</label>
            <input type="hidden" id="totalPageCount" th:value="${page.totalPageCount}"/>
            <input type="text" name="inputPage" size="1" id="inputPage" class="page-key"/>页
            <button type="button" class="page-btn"
                    th:onClick="'jumpPage(document.forms[0],document.getElementById(\''+inputPage+'\').value)'">GO</button>
            </span>
</div>
</body>
<script type="text/javascript" src="../../js/jquery-3.2.1.min.js"></script>
<script type="text/javascript" src="/laydate/laydate.js"></script>
<script type="text/javascript" src="/layer/layer.js"></script>
<!-- plugins:js -->
<script src="/vendors/js/vendor.bundle.base.js"></script>
<script src="/vendors/js/vendor.bundle.addons.js"></script>
<!-- endinject -->
<!-- Plugin js for this page-->
<!-- End plugin js for this page-->
<!-- inject:js -->
<script src="/js/off-canvas.js"></script>
<script src="/js/misc.js"></script>
<!-- endinject -->
<!-- Custom js for this page-->
<script src="/js/dashboard.js"></script>
<!-- End custom js for this page-->
<script type="text/javascript">
    // <![CDATA[
    laydate.render({
        elem: '#test1', //指定元素
        type: "date",
        range: true
    });

    //01.分页查询
    function pageQry(form, pageIndex) {
        form.currentPageNo.value = pageIndex;//赋值给【分页+条件查询的表单】
        form.submit();//用js主动提交
    }

    //02.跳转页查询
    function jumpPage(form, jumpPageIndex) {
        //01.数字校验
        var reg = /^[1-9]\d{0,}$/;
        if (!reg.test(parseInt(jumpPageIndex))) {
            layer.msg("请输入合法的数字", {time: 1000});
            return;
        }
        //02.范围校验：当前页不能大于总页数
        if (jumpPageIndex > document.getElementById("totalPageCount").value) {
            layer.msg("已经是最后一页!");
            return;
        }
        form.currentPageNo.value = jumpPageIndex;
        form.submit();
    }

    $(function () {
        $(".Check").click(function () {
            var boID = $(this).parent().parent().children().eq(0).html();
            $("#CheckStatecheckboId").val(boID);
            var mApproveMoney = $(this).parent().parent().children().eq(5).html();
            $("#mApproveMoney").val(mApproveMoney);
        });
        $("#addBtn").click(function () {
            $.ajax({
                url: "/Contract/choose",
                data: {
                    "boID": $("#CheckStatecheckboId").val(),
                    "contractNo": $("#exampleInputName3 option:selected").val(),
                    "mApproveMoney":$("#mApproveMoney").val()
                },
                type: "post",
                dataType: "JSON",
                success: function (data) {
                    if (data == true) {
                        layer.msg("发送成功", {time: 1000});
                    } else {
                        layer.msg("发送失败", {time: 1000});
                    }
                    setTimeout(function () {
                        window.location.href = 'http://localhost:8004/contractManger/query?currentPageNo=1';
                    }, 1000);
                }
            })
        });
        $(".checkConstract").click(function () {
            //合同预览页面
            window.open("http://localhost:8004/upload/%E7%99%BD%E5%90%88%E5%90%8C.pdf");
        });
    })

    // ]]>
</script>
</html>